<?php
	//判断上传不能为空
	if(!empty($_FILES['upFile']['name'])){
		header("content-type:text/html;charset=utf-8");		
		//获取原图片名字
		$oldName = $_FILES['upFile']['name'];
		//把原始名字转为数组形式
		$tmp = explode('.',$oldName);
		//时间戳重新命名
		$newName = time().".".$tmp['1'];
		//指定文件上传路径
		$filePath = 'images/'.$newName;
		//上传文件判断
		if(is_uploaded_file($_FILES['upFile']['tmp_name'])){
		  //开始移动文件到相应的文件夹 
		  if(move_uploaded_file($_FILES['upFile']['tmp_name'], $filePath)){
		    echo '上传成功';

		    $con = mysql_connect('localhost','root','root');
			$db = mysql_select_db('img',$con);
			mysql_query("SET NAMES UTF8");
		    $sql = "insert into `img` (`oldName`,`newName`) values ('".$oldName."','".$newName."')";
		    $query = mysql_query($sql);
			}
		}
	}else{
		header("content-type:text/html;charset=utf-8");		
		echo "内容错误";
	}

?>